<template>
	<view class="passenger-flow">
		<!-- <nav-bar title="课程中心" :color="navBarColor" :bg="navBarBg"></nav-bar> -->
		<view class="box_9" style="">
			<con-venues :itemChooselist='itemChooselist' :venuelist='venuelist' @confirm="confirm1"></con-venues>
			<view style="position: fixed;z-index: 999;width: 100%;top: 120rpx;">
				<view class="box_11">
					<view class="image-wrapper_7">
						<u-search @search="search" @custom="search" placeholder="搜索" :showAction="false"
							v-model="searchKey">
						</u-search>
					</view>
					<view class="label_list" @click="tianjiaclick">
						<image
							src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/0555f554c12d0d628b0e4e3e90147966755aa715.png"
							class="label_7"></image>
						<view class="label_77">
							添加
						</view>
					</view>
					<view class="label8_list">
						<image
							src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/a0caafa1d0f5c11490a41f203aab143debf439d6.png"
							class="label_8"></image>
						<view class="label_88">
							<HM-filterDropdown :menuTop="88" :filterData="filterData" :defaultSelected="defaultSelected"
								:updateMenuName="true" @confirm="confirm" dataFormat="Object"></HM-filterDropdown>
						</view>
					</view>
				</view>
				<!-- <view class="">
					<view class="item">
						<view class="flex-space-between week-list">
							<view class="week-item" :class="{'active':index === selectId}"
								v-for="(item,index) in timeList" :key="index" @click="timesSelect(item,index)">
								{{item.name}}
							</view>
						</view>
					</view>
					<view class="item">
						<view class="flex-space-between week-list">
							<view class="week-item" :class="{'active':index === liemuId}"
								v-for="(item,index) in liemuList" :key="index" @click="liemuSelect(item,index)">
								{{item.name}}
							</view>
						</view>
					</view>
					<view class="item">
						<view class="flex-space-between week-list">
							<view class="week-item" :class="{'active':index === weekId}"
								v-for="(item,index) in weekList" :key="index" @click="weekSelect(item,index)">
								{{item.name}}
							</view>
						</view>
					</view>
				</view>
				<view class="">
					<view class="d-flex flex-column "
						style="width: 96%;margin-top: 30rpx;margin-left: 2%;padding: 0 20rpx;">
						<u-search @search="search" @custom="search" placeholder="搜索课程" :showAction="false"
							shape="square" v-model="searchKey">
						</u-search>
					</view>
				</view> -->
			</view>
			<view class="" style="margin-top: 74rpx;">
				<scroll-view scroll-y class="listall" v-for="(item,index) in Cardlist" :key="index">
					<v-gap />
					<view class="d-flex flex-row"
						style="background-color: #fff;width: 94%;padding: 30rpx;margin-left: 3%;">
						<!-- <view class="d-flex flex-column align-center">
							<view class="">
								<image style="width: 160rpx;height: 160rpx;" src="../../static/logo.png" mode="">
								</image>
							</view>
							<view class="" style="color: #ff5500;margin-top: 20rpx;">
								¥1299
							</view>
						</view> -->
						<view class="d-flex flex-column" style="width: 100%;">
							<view class="">
								<view class="" style="font-size: 28rpx;">
									{{item.course_item_name}}
								</view>
							</view>
							<view class="" style="margin-top: 20rpx;">
								<view class="d-flex flex-row justify-space-between">
									<view class="d-flex flex-row ">
										<view class="d-flex flex-row align-center justify-center">
											<!-- <image class="" style="width: 20rpx;height: 20rpx;"
												src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a70accdc329c0011116ca9/16731594763839302067.png" /> -->
											<view class="" style="margin-left: 10rpx;font-size: 22rpx; color: #b8b8b8;">
												{{item.course_mode_type_name}}
											</view>
										</view>
										<view class="d-flex flex-row  align-center justify-center"
											style="margin-left: 40rpx;">
											<!-- <image class="" style="width: 20rpx;height: 20rpx;"
												src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a70accdc329c0011116ca9/16731594764081021110.png" /> -->
											<view class="" style="margin-left: 10rpx;font-size: 22rpx; color: #b8b8b8;">
												{{item.course_name}}
											</view>
										</view>
									</view>
									<view class=""
										style="width: 80rpx;height: 40rpx;background: #ffffff;color: #7cc57e;font-size: 22rpx;text-align: center;margin-right: 20rpx;line-height: 40rpx;border: 1rpx #7cc57e solid;">
										在售
									</view>
								</view>
							</view>
							<view class="" style="margin-top: 20rpx;">
								<view class="">
									<view class="d-flex flex-row">
										<view class="d-flex flex-row  align-center justify-center">
											<!-- <image class="" style="width: 20rpx;height: 20rpx;"
												src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a70accdc329c0011116ca9/16731594763839302067.png" /> -->
											<view class="" style="margin-left: 10rpx;font-size: 22rpx; color: #b8b8b8;">
												课次:12次
											</view>
										</view>
										<view class="d-flex flex-row align-center justify-center"
											style="margin-left: 40rpx;">
											<!-- <image class="" style="width: 20rpx;height: 20rpx;"
												src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a70accdc329c0011116ca9/16731594764081021110.png" /> -->
											<view class="" style="margin-left: 10rpx;font-size: 22rpx; color: #b8b8b8;">
												2021-12-30
											</view>
										</view>
									</view>
								</view>
							</view>
							<view class="" style="margin-top: 20rpx;">
								<view class="d-flex flex-row justify-space-between">
									<view class="d-flex flex-row align-center">
										
										<view class="d-flex flex-row">
											<view class="d-flex flex-row  align-center justify-center">
												<!-- <image class="" style="width: 20rpx;height: 20rpx;"
													src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a70accdc329c0011116ca9/16731594763839302067.png" /> -->
												<view class=""
													style="margin-left: 10rpx;font-size: 22rpx; color: #b8b8b8;">
													库存:20件
												</view>
											</view>
											<view class="d-flex flex-row align-center justify-center"
												style="margin-left: 40rpx;">
												<!-- <image class="" style="width: 20rpx;height: 20rpx;"
													src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a70accdc329c0011116ca9/16731594764081021110.png" /> -->
												<view class=""
													style="margin-left: 10rpx;font-size: 22rpx; color: #b8b8b8;">
													销售:120件
												</view>
											</view>
										</view>
									</view>
									<view class="" style="color: #ff5500;margin-top: 20rpx;">
										¥1299
									</view>
								</view>
							</view>
							<view class="" style="margin-top: 20rpx;">
								<view class="">
									<view class="d-flex flex-row" style=" justify-content: flex-end">
										<view class="d-flex flex-row align-center justify-center" style="width: 67px;height: 26px;color: #ffffff;font-size: 12px;text-align: center;border-radius: 5px;line-height: 26px;background-color: #53c557;margin-right: 5px;">
											<!-- <image class="" style="width: 20rpx;height: 20rpx;"
												src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a70accdc329c0011116ca9/16731594764081021110.png" /> -->
											<view class="" style="margin-left: 10rpx;font-size: 22rpx;">
												删除
											</view>
										</view>
										<view class="d-flex flex-row align-center justify-center" style="width: 67px;height: 26px;color: #ffffff;font-size: 12px;text-align: center;border-radius: 5px;line-height: 26px;background-color: #4c9dff;">
											<!-- <image class="" style="width: 20rpx;height: 20rpx;"
												src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a70accdc329c0011116ca9/16731594764081021110.png" /> -->
											<view class="" style="margin-left: 10rpx;font-size: 22rpx;">
												编辑
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</scroll-view>
				<v-gap height="140rpx" color="#EDF5F5" />
			</view>
			<view class="d-flex flex-row justify-space-between justify-center align-center"
				style="position: fixed;bottom: 0;height: 120rpx;background-color: #fff;width: 100%;padding: 0 8%;z-index: 99;">
				<view class=""
					style="width: 45%;height: 80rpx;background: #ffffff;color: #ec652b;font-size: 24rpx;text-align: center;border-radius: 35rpx;line-height: 80rpx;border:#ec652b 1rpx solid">
					批量操作
				</view>
				<view class="" @click="addculum"
					style="width: 45%;height: 80rpx;background: linear-gradient(0deg, rgba(214, 53, 53, 0.9), rgba(255, 64, 64, 0.93), rgba(250, 142, 142, 0.93));color: #ffffff;font-size: 24rpx;text-align: center;border-radius: 35rpx;line-height: 80rpx;">
					添加课程
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	const lastdata = [{
		"name": '筛选',
		"type": 'filter',
		"submenu": [{
				"name": "性别",
				"submenu": [{
						"name": "男",
						"value": "1"
					},
					{
						"name": "女",
						"value": "2"
					}
				]
			},
			{
				"name": "机构",
				"submenu": [{
						"name": "总部",
						"value": "1"
					},
					{
						"name": "分布A",
						"value": "2"
					},
					{
						"name": "分布B",
						"value": "3"
					}
				]
			},
			{
				"name": "转态",
				"submenu": [{
						"name": "在读",
						"value": "4"
					},
					{
						"name": "休学",
						"value": "5"
					},
					{
						"name": "结业",
						"value": "6"
					}
				]
			},
			{
				"name": "年龄",
				"submenu": [{
						"name": "6-8岁",
						"value": "4"
					},
					{
						"name": "9-12岁",
						"value": "5"
					},
					{
						"name": "13-15岁",
						"value": "6"
					}
				]
			}
		]
	}];
	import navbar from '@/mixins/navbar.js';
	const train = require("@/api/train/index.js");
	export default {
		mixins: [navbar({
			navBarColor: '#000000'
		})],
		data() {
			return {
				selectId: 0,
				timeList: [{
						name: '全部',
						id: '1'
					},
					{
						name: '在售',
						id: '2'
					},
					{
						name: '已下架',
						id: '3'
					}
				],
				liemuId: 0,
				liemuList: [{
						name: '全部',
						id: '1'
					},
					{
						name: '瑜伽',
						id: '2'
					},
					{
						name: '篮球',
						id: '3'
					}
				],
				weekId: 0,
				weekList: [{
						name: '本周',
						id: '1'
					},
					{
						name: '本月',
						id: '2'
					},
					{
						name: '三个月',
						id: '3'
					},
					{
						name: '半年',
						id: '4'
					}
				],
				itemChooselist: {},
				venuelist: [],
				filterData: [],
				listQuery: { //分页
					pageNo: 1,
					pageSize: 10,
				},
				totalPage: '', //几页
				Cardlist: [],
				totalPage: ''
			}
		},
		onLoad(options) {
			var data = uni.getStorageSync("wqzdy");
			var items = JSON.parse(data)
			this.venuelist = items
			// this.itemChooselist = this.venuelist[0]
			// 处理itemChooselist的逻辑
			if (this.venuelist.length > 0) {
				this.itemChooselist = this.venuelist[0]
			} else {
				this.itemChooselist = {}; // 或者设置为其他默认值
			}
			setTimeout(() => {
				this.filterData = lastdata;
			}, 100);
			this.trainpackage()
		},
		methods: {
			async trainpackage() {
				let that = this;
				if (this.listQuery.pageNo == 1) that.Cardlist = [];
				let params = {
					venue_id: this.itemChooselist.id,
					page: this.listQuery.pageNo,
					pageSize: this.listQuery.pageSize,
				};
				let res = await train.trainpackage(params);
				if (res.code == 1) {
					that.Cardlist = that.Cardlist.concat(res.data.list.data); //将数据拼接在一起
					that.totalPage = res.data.list.last_page
				}
			},
			onReachBottom() {
				if (this.totalPage <= this.listQuery.pageNo) {
					uni.showToast({
						title: '没有更多了',
						duration: 2000,
						icon: 'none'
					});
					return
				}
				this.listQuery.pageNo += 1;
				this.trainpackage()
			},
			addculum() {
				uni.navigateTo({
					url: '../addculum/index'
				})
			},
			confirm(e) {
				// this.indexArr = e.index;
				// this.valueArr = e.value;
			},
			confirm1(data) {
				this.venue_id = data
			    console.log(data, 'data');
			    // 直接根据接收到的 id 在 venuelist 中查找对应的场馆对象
			    const selectedItem = this.venuelist.find(item => item.id === data);
			    if (selectedItem) {
			        // 将找到的场馆对象赋值给 itemChooselist
			        this.itemChooselist = selectedItem;
			    } else {
			        console.log(`未找到 id 为 ${data} 的场馆对象`);
			    }
			},
			timesSelect(item, index) {
				this.selectId = index
			},
			liemuSelect(item, index) {
				this.liemuId = index
			},
			weekSelect(item, index) {
				this.weekId = index
			},
		}
	}
</script>


<style lang="less" scoped>
	.passenger-flow {
		width: 100%;
		min-height: 100vh;
		display: flex;
		flex-direction: column;
		background-color: #EDF5F5;
		padding: 0rpx 0 50rpx 0;
		position: relative;

		.box_9 {
			width: 750rpx;
			height: 100%;
			// margin-bottom: 1rpx;
			display: flex;
			flex-direction: column;

			.box_11 {
				width: 100%;
				height: 130rpx;
				display: flex;
				flex-direction: row;
				background: #ffffff;
				padding: 0 20rpx;

				// .image-wrapper_7 {
				// 	width: 541rpx;
				// 	height: 60rpx;
				// 	flex-direction: row;
				// 	display: flex;
				// 	margin-top: 15rpx;
				// }
				.image-wrapper_7 {
					position: absolute;
					left: 30rpx;
					top: 30rpx;
					width: 541rpx;
					height: 62rpx;
					flex-direction: row;
					display: flex;
				}

				.label_list {
					display: flex;
					flex-direction: column;
					position: absolute;
					justify-content: center;
					/* 相对父元素水平居中 */
					align-items: center;
					/*  子元素相对父元素垂直居中 */
					right: 90rpx;
					width: 80rpx;
					top: 27rpx;

					.label_7 {
						width: 36rpx;
						height: 36rpx;
					}

					.label_77 {
						width: 60rpx;
						height: 36rpx;
						color: #333333;
						font-size: 26rpx;
						text-align: center;
					}
				}

				.label8_list {
					display: flex;
					flex-direction: column;
					position: absolute;
					justify-content: center;
					/* 相对父元素水平居中 */
					align-items: center;
					/*  子元素相对父元素垂直居中 */
					right: 20rpx;
					width: 80rpx;
					top: 27rpx;

					.label_8 {
						width: 36rpx;
						height: 36rpx;
					}

					.label_88 {
						width: 60rpx;
						height: 36rpx;
						color: #333333;
						font-size: 26rpx;
						text-align: center;
					}
				}
			}

			.item {
				margin: 30rpx 30rpx 0 20rpx;

				.week-list {
					display: grid;
					grid-template-columns: repeat(5, 1fr);
					grid-gap: 20rpx;
					position: relative;

					.week-item {
						padding: 15rpx 15rpx 15rpx 0;
						background-color: rgb(243, 243, 243);
						border-radius: 5rpx;
						text-align: center;
						color: rgb(51, 51, 51);
						font-size: 24rpx;
						font-weight: 500;
						border: solid 2rpx transparent;
						box-sizing: border-box;
					}

					.active {
						color: rgba(255, 98, 0, 1);
						background-color: rgba(255, 65, 5, 0.1);
						// border: solid 2rpx rgb(99, 93, 247);
						position: relative;

						// &:before {
						// 	display: block;
						// 	content: '';
						// 	position: absolute;
						// 	width: 27rpx;
						// 	height: 28rpx;
						// 	right: -2rpx;
						// 	bottom: -2rpx;
						// 	background-image: url("https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/46b1cc85fcb0fd76095daf823b7d2bb4a3235519.png");
						// 	background-repeat: no-repeat;
						// 	background-size: 100%;
						// }
					}

					.active1 {
						color: rgba(255, 98, 0, 1);
						background-color: rgba(255, 65, 5, 0.1);
						// border: solid 2rpx rgb(99, 93, 247);
						position: relative;
					}

					.active2 {
						color: rgba(255, 98, 0, 1);
						background-color: rgba(255, 65, 5, 0.1);
						// border: solid 2rpx rgb(99, 93, 247);
						position: relative;
					}

					.check {
						color: rgb(51, 51, 51);
						font-size: 24rpx;
						position: absolute;
						bottom: 10rpx;
						right: 0;
					}
				}
			}
		}
	}
</style>